﻿
@{
    ViewBag.Title = "修改店铺";
}
@section CSS{
    <link href="~/Content/css/layerui/layui.css" rel="stylesheet" />
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            修改
            <small>店铺</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">商家管理</a></li>
            <li><a href="/shop/company">店铺列表</a></li>
            <li class="active">修改店铺</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <div class="ibox float-e-margins">
                            <div class="ibox float-e-margins">
                                <div class="ibox-content">
                                    @if (Model != null)
                                    {
                                        <form class="form-horizontal" id="from-add" novalidate="novalidate" method="post" action="/shop/AddorEditShopInfo">
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">店铺名称：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.name</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">店铺类型：</label>
                                                <div class="col-sm-9 ">
                                                    <span class="help-block m-b-none">
                                                        @(Model.grade==0? "普通店" : (Model.grade == 1 ? "专营店" : (Model.grade == 2 ? "专卖店" : (Model.grade == 3 ? "旗舰店" : ""))))
                                                    </span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">店铺Logo：</label>
                                                <div class="col-sm-9">
                                                    <div class="layui-upload-list">
                                                        <img class="layui-upload-img" id="logo_img" onclick="javascript:imgzoom(this.id)" style="width: 150px; height: 150px; cursor: pointer">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">账期：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.account_period 天</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">店铺管理人姓名：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.mangername</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">管理人手机号码 <span style="color:red;">*</span>：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.mangermobile</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">管理人QQ号：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.qq</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">管理人微信号：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.wechat</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">管理人邮箱：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.email</span>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">管理人身份证信息：</label>
                                                <div class="col-sm-3">
                                                    <div class="layui-upload">
                                                        <div class="layui-upload-list">
                                                            <img class="layui-upload-img" id="face_card_img" onclick="javascript:imgzoom(this.id)" style="width: 150px; height: 150px; cursor: pointer">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="col-sm-3">
                                                    <div class="layui-upload">
                                                        <div class="layui-upload-list">
                                                            <img class="layui-upload-img" id="opposite_card_img" onclick="javascript:imgzoom(this.id)" style="width: 150px; height: 150px; cursor: pointer">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="col-sm-3">
                                                    <div class="layui-upload">
                                                        <div class="layui-upload-list">
                                                            <img class="layui-upload-img" id="half_card_img" onclick="javascript:imgzoom(this.id)" style="width: 150px; height: 150px; cursor: pointer">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">管理人身份证有效期：</label>
                                                <div class="col-sm-3">
                                                    <span class="help-block m-b-none" >@(Model.card_date == null ? "" :Model.card_date.ToString("yyyy-MM-dd"))</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">开店起止日期：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@(Model.start_date == null ? "" : Model.start_date.ToString("yyyy-MM-dd")) ~ @(Model.end_date == null ? "" : Model.end_date.ToString("yyyy-MM-dd")) </span>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>

                                            <input type="hidden" id="id" value="0" name="id">
                                            <input type="hidden" id="supplier_id" value="0" name="supplier_id">
                                            <input type="hidden" id="half_card" value="" name="half_card">
                                            <input type="hidden" id="opposite_card" value="" name="opposite_card">
                                            <input type="hidden" id="face_card" value="" name="face_card">
                                            <input type="hidden" id="logo" value="" name="logo">
                                            <input type="hidden" id="grade" value="0" name="grade">
                                        </form>
                                    }

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

</div>

@section JS{
    @*<script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/Content/plugins/validate/messages_zh.min.js"></script>*@

<script type="text/javascript">
         var _id="@ViewBag.id";

        $(function () {
            if (_id != undefined && _id!="0")
            {
                //getinfo(_id);
                var logo = '@(Model==null?"": Model.logo)';
                var opposite_card = '@(Model==null?"": Model.opposite_card)';
                var face_card = '@(Model==null?"": Model.face_card)';
                var half_card = '@(Model==null?"": Model.half_card)';
                   if (logo!="") {
                        $("#logo_img").attr('src', domain + logo);
                    }
                    if (opposite_card != "") {
                        $("#opposite_card_img").attr('src', domain + opposite_card);
                    }
                    if (face_card != "") {
                        $("#face_card_img").attr('src', domain + face_card);
                    }
                    if (half_card != "") {
                        $("#half_card_img").attr('src', domain + half_card);
                    }
            }
            else{
                layer.alert('信息获取失败，请重试！', { icon: 5 });
             }
        });


        function getinfo(_id) {
            ajax("/setting/GetStoreInfo", {}, function (data) {
                if (data!= null) {
                    $("#id").val(data.id);
                    $("#name").val(data.name);
                    $("#wechat").val(data.wechat);
                    $("#qq").val(data.qq);
                    $("#email").val(data.email);
                    $("#grade").val(data.grade);
                    $("#sGrade").val(data.grade);
                    $("#account_period").val(data.account_period);
                    if (data.logo!="") {
                        $("#logo_img").attr('src', domain + data.logo);
                    }
                    if (data.opposite_card != "") {
                        $("#opposite_card_img").attr('src', domain + data.opposite_card);
                    }
                    if (data.face_card != "") {
                        $("#face_card_img").attr('src', domain + data.face_card);
                    }
                    if (data.half_card != "") {
                        $("#half_card_img").attr('src', domain + data.half_card);
                    }
                    $("#logo").val(data.logo);
                    $("#half_card").val(data.half_card);
                    $("#face_card").val(data.face_card);
                    $("#opposite_card").val(data.opposite_card);
                    $("#card_date").val((data.card_date==null?"":moment(data.card_date).format("YYYY-MM-DD")));
                    $("#start_date").val((data.start_date==null?"":moment(data.start_date).format("YYYY-MM-DD")));
                    $("#end_date").val((data.end_date==null?"":moment(data.end_date).format("YYYY-MM-DD")));
                    $("#mangername").val(data.mangername);
                    $("#mangermobile").val(data.mangermobile);
                    //店铺唯一，禁止修改
                    $("#name").attr("readonly", "readonly");
                    $("#mangermobile").attr("readonly", "readonly");
                }
                else {
                    layer.alert('信息获取失败，请重试！', { icon: 5 });
                }
            }, true, "", "get");
        }
        $("#sGrade").change(function () {
            var _mId = $(this).val();
            if (_mId != "") {
                $("#grade").val(_mId);
            }
        });


        //图片点击跳转
        function imgzoom(obj) {
            var img = document.getElementById(obj).src
            if (!!img) {
                onclick = window.open(img)
            }
        }

</script>
}


